//
//  Common.h
//  WisdomZhuHai
//
//  Created by yewei on 13-8-9.
//  Copyright (c) 2013年 wyd. All rights reserved.
//

#ifndef WisdomZhuHai_Common_h
#define WisdomZhuHai_Common_h

#import <CoreLocation/CoreLocation.h>
#import "FileManager.h"
#import "UIWebControl.h"
#import "BaseTableViewController.h"
#import "BaseViewController.h"
#import "CustomLoadingView.h"
#import "HttpRequestManager.h"
#import "AppDelegate.h"
#import "ConfigManager.h"
#import <Availability.h>
#import "ConfigManager.h"
#import "Define.h"
#import "ProtocolManager.h"

//define
#ifndef INVALIDCOORDINATE
#define INVALIDCOORDINATE (CLLocationCoordinate2DMake(-9999, -9999))
#endif
#ifndef CHECKCOORDINATEISVALID
#define CHECKCOORDINATEISVALID(x) (!((x).latitude == -9999 && (x).longitude == -9999))
#endif

#ifndef GETVALUEBYKEY
#define GETVALUEBYKEY(key, dic) ([JsonDataManager CheckObjectFromJSONStringIsNSNull:[(dic) objectForKey:(key)]])
#endif
#ifndef CHECKKEYISVALID
#define CHECKKEYISVALID(key, dic) (![GETVALUEBYKEY(key, dic) isEqualToString:@""])
#endif

//自定义通知事件
#define NOTIFIY_REGISTER_SUCCESS @"notifyRegisterSuccess"   //注册成功通知
#define NOTIFIY_LOGIN_SUCCESS @"notifyLoginSuccess"         //登陆成功通知


enum regexType{
    e_email = 0,
    e_url,
    e_number,
    e_phoneNumber,
};

typedef NS_ENUM(NSInteger, PlaceholderImgType) {
    ePIT_StoreType,
    ePIT_StoreLogo,
    ePIT_StorePhoto,
    ePIT_Strategy,
};

@interface Common : NSObject<UIAlertViewDelegate>

@property CLLocationCoordinate2D adjustCoordinateForGoogle;
@property (nonatomic) CGRect contentFrame;
@property (nonatomic) CGRect contentFrameNoTabBar;

+ (Common*)shareInstance;
+ (CLLocationCoordinate2D)getCoordinateFromString:(NSString*)str;
+ (NSURL*)getUrlByString:(NSString*)url;
+ (BOOL)checkNetReachable;

//获取${xxx}格式的xxx
+ (NSString *)getValueByFormatString:(NSString *)str;
//获取本地用户信息
+ (NSDictionary*)getUserAccountInfo:(NSString *)str;
//根据字符串是否符合指定类型的格式
+ (BOOL)regexWithType:(int)type string:(NSString *)str;

+ (UIColor*)colorWithRGB:(unsigned int)RGBValue;//RGBValue:0x834697
+ (UIColor*)colorWithRGB:(unsigned int)RGBValue alpha:(CGFloat)alpha;//RGBValue:0x834697

+ (UIImage*)imageWithColor:(UIColor*)color;

+ (CGFloat)getIosVersion;

+ (UIImage*)getPlaceholderImage:(PlaceholderImgType)type;

//获取在主服务器里面的资源下载全路径
+ (NSURL *)getFullDownloadPathByRelativePath:(NSString *)relativePath;

//根据传入的字符串，筛选出电话好吗，并提供拨号功能
-(void)callWithPhoneString:(NSString *)phoneString inView:(UIView *)view;

//获取今天的日期,格式为2013-02-01
-(NSString *)getDate;

//获取今天的时间，格式为15:20:20
-(NSString *)getTimeOfToday;

//是否是高清屏幕
-(BOOL)isRetinaMode;

-(CLLocationCoordinate2D)AdjustLocationCoordinateForGoogle:(CLLocationCoordinate2D)coor;

//自动消失的alertView
- (void)showAlertViewWithTitle:(NSString *)title text:(NSString *)text dismissTime:(float)second;
- (void)showAlertViewWithTitle:(NSString *)title text:(NSString *)text dismissTime:(float)second dismissed:(void(^)())block;

//自定义valueForkey对 [NSull null]做判断处理
+(id)valueForKey:(NSString *)key dic:(NSDictionary *)dic;
//计算文本的大小，为了兼容ios 7和低版本统一接口
+(CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size string:(NSString *)str;
-(void)showLoadingViewWithMessage:(NSString *)message;
-(void)stopLoadingView;

//获得设备的物理地址
+(NSString *)getMacAddr;

//判断是否是新的版本
+(BOOL)isNewAppVersion:(NSString *)version;
@end

#endif
